package AbstractFactory;

public class AbstractFactory {
    public static void main(String[] args) {
        FactoryB a = new FactoryB();
        a.createPhone().print();
    }
}

abstract class  Factory{
    public abstract Phone createPhone();
    public abstract Mask createMask();
}

class FactoryA extends Factory{
    @Override
    public Phone createPhone() {
        return new iPhone();
    }

    @Override
    public Mask createMask() {
        return new N95();
    }
}

class FactoryB extends Factory{
    @Override
    public Phone createPhone() {
        return new HuaweiPhone();
    }

    @Override
    public Mask createMask() {
        return new KN95();
    }
}

interface Phone{
    void print();
}
class iPhone implements Phone{
    @Override
    public void print() {
        System.out.println("AbstractFactory.iPhone");
    }
}
class HuaweiPhone implements Phone{
    @Override
    public void print() {
        System.out.println("华为");
    }
}
interface Mask{
    void print();
}
class N95 implements Mask{
    @Override
    public void print() {
        System.out.println("AbstractFactory.N95");
    }
}
class KN95 implements Mask{
    @Override
    public void print() {
        System.out.println("AbstractFactory.KN95");
    }
}






